using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

using WorkflowApplicationsData = Scenario.WorkflowEngine.DataModel.WorkflowApplicationsData;

namespace Scenario.Modeler
{
	/// <summary>
	/// Descrizione di riepilogo per Applications.
	/// </summary>
	public class Applications : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Panel panel1;
		private System.Windows.Forms.ListView listApplications;
		private System.Windows.Forms.Button btnClose;
		private System.Windows.Forms.Button btnAdd;
		private System.Windows.Forms.Button btnModify;
		private System.Windows.Forms.Button btnDelete;
		/// <summary>
		/// Variabile di progettazione necessaria.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Applications()
		{
			//
			// Necessario per il supporto di Progettazione Windows Form
			//
			InitializeComponent();

			//
			// TODO: aggiungere il codice del costruttore dopo la chiamata a InitializeComponent
			//
		}

		/// <summary>
		/// Pulire le risorse in uso.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Codice generato da Progettazione Windows Form
		/// <summary>
		/// Metodo necessario per il supporto della finestra di progettazione. Non modificare
		/// il contenuto del metodo con l'editor di codice.
		/// </summary>
		private void InitializeComponent()
		{
			this.listApplications = new System.Windows.Forms.ListView();
			this.panel1 = new System.Windows.Forms.Panel();
			this.btnClose = new System.Windows.Forms.Button();
			this.btnDelete = new System.Windows.Forms.Button();
			this.btnModify = new System.Windows.Forms.Button();
			this.btnAdd = new System.Windows.Forms.Button();
			this.panel1.SuspendLayout();
			this.SuspendLayout();
			// 
			// listApplications
			// 
			this.listApplications.Location = new System.Drawing.Point(8, 16);
			this.listApplications.Name = "listApplications";
			this.listApplications.Size = new System.Drawing.Size(1032, 624);
			this.listApplications.TabIndex = 0;
			this.listApplications.View = System.Windows.Forms.View.Details;
			// 
			// panel1
			// 
			this.panel1.Controls.Add(this.btnClose);
			this.panel1.Controls.Add(this.btnModify);
			this.panel1.Controls.Add(this.btnAdd);
			this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
			this.panel1.Location = new System.Drawing.Point(0, 651);
			this.panel1.Name = "panel1";
			this.panel1.Size = new System.Drawing.Size(1048, 64);
			this.panel1.TabIndex = 1;
			// 
			// btnClose
			// 
			this.btnClose.Location = new System.Drawing.Point(648, 16);
			this.btnClose.Name = "btnClose";
			this.btnClose.Size = new System.Drawing.Size(144, 32);
			this.btnClose.TabIndex = 3;
			this.btnClose.Text = "Close";
			this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
			// 
			// btnDelete
			// 
			this.btnDelete.Location = new System.Drawing.Point(0, 0);
			this.btnDelete.Name = "btnDelete";
			this.btnDelete.TabIndex = 0;
			// 
			// btnModify
			// 
			this.btnModify.Location = new System.Drawing.Point(400, 16);
			this.btnModify.Name = "btnModify";
			this.btnModify.Size = new System.Drawing.Size(168, 32);
			this.btnModify.TabIndex = 1;
			this.btnModify.Text = "Modify";
			// 
			// btnAdd
			// 
			this.btnAdd.Location = new System.Drawing.Point(136, 16);
			this.btnAdd.Name = "btnAdd";
			this.btnAdd.Size = new System.Drawing.Size(152, 32);
			this.btnAdd.TabIndex = 0;
			this.btnAdd.Text = "Add";
			// 
			// Applications
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
			this.ClientSize = new System.Drawing.Size(1048, 715);
			this.Controls.Add(this.panel1);
			this.Controls.Add(this.listApplications);
			this.Name = "Applications";
			this.Text = "Applications";
			this.Load += new System.EventHandler(this.Applications_Load);
			this.panel1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void Applications_Load(object sender, System.EventArgs e)
		{
			listApplications.Clear();
			listApplications.Columns.Add("Name",listApplications.Width - 400, HorizontalAlignment.Left);
			listApplications.Columns.Add("Type",200, HorizontalAlignment.Left);
			listApplications.Columns.Add("Library",200, HorizontalAlignment.Left);

            WAPI.ApplicationHelper helper = new WAPI.ApplicationHelper();
			WorkflowApplicationsData.XMLApplications vApplications = helper.GetApplications();

			for ( int i=0; i<vApplications.Count; i++)
			{
				WorkflowApplicationsData.XMLApplication application = (WorkflowApplicationsData.XMLApplication) vApplications[i];
				ListViewItem item =null;
				item = new ListViewItem( new string[] { application.Name, application.Type, application.LibraryFile });

				listApplications.Items.Add ( item);
			}
		}

		private void btnClose_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}
	}
}
